package net.atomarrow.util;
/**
 * String连接工具类
 * @author Michael
 *
 */
public class StringLink implements java.io.Serializable, CharSequence{
	private StringBuilder sb;

	public StringLink(Object... args) {
		sb = new StringBuilder();
		for (Object arg : args) {
			sb.append(arg);
		}
	}

	public StringBuilder append(Object arg) {
		return sb.append(arg);
	}

	public void setLength(int len) {
		sb.setLength(len);
	}

	@Override
	public String toString() {
		return sb.toString();
	}

	static final long serialVersionUID = 4383685877147921099L;

	public StringLink() {
		sb=new StringBuilder();
	}

	public StringLink(int capacity) {
		sb=new StringBuilder(capacity);
	}

	public StringLink(String str) {
		sb=new StringBuilder(str);
	}

	public StringLink(CharSequence seq) {
		sb=new StringBuilder(seq);
	}

	public StringBuilder append(StringBuffer sbs) {
		return sb.append(sbs);
	}

	public StringBuilder append(CharSequence s) {
		if (s == null)
			s = "null";
		if (s instanceof String)
			return sb.append((String) s);
		if (s instanceof StringBuffer)
			return sb.append((StringBuffer) s);
		if (s instanceof StringBuilder)
			return sb.append(s);
		return sb.append(s, 0, s.length());
	}

	public StringBuilder append(CharSequence s, int start, int end) {
		return sb.append(s, start, end);
	}


	public StringBuilder append(char[] str, int offset, int len) {
		return sb.append(str, offset, len);
	}


	public StringBuilder appendCodePoint(int codePoint) {
		return sb.appendCodePoint(codePoint);
	}

	public StringBuilder delete(int start, int end) {
		return sb.delete(start, end);
	}

	public StringBuilder deleteCharAt(int index) {
		return sb.deleteCharAt(index);
	}

	public StringBuilder replace(int start, int end, String str) {
		return sb.replace(start, end, str);
	}

	public StringBuilder insert(int index, char[] str, int offset, int len) {
		return sb.insert(index, str, offset, len);
	}

	public StringBuilder insert(int offset, Object obj) {
		return insert(offset, String.valueOf(obj));
	}

	

	public StringBuilder insert(int dstOffset, CharSequence s) {
		return sb.insert(dstOffset, s);
	}

	public StringBuilder insert(int dstOffset, CharSequence s, int start,
			int end) {
		return sb.insert(dstOffset, s, start, end);
	}

	public StringBuilder insert(int offset, boolean b) {
		return sb.insert(offset, b);
	}

	public StringBuilder insert(int offset, char c) {
		return sb.insert(offset, c);
	}

	public StringBuilder insert(int offset, int i) {
		return sb.insert(offset, i);
	}

	public StringBuilder insert(int offset, long l) {
		return sb.insert(offset, l);
	}

	public StringBuilder insert(int offset, float f) {
		return sb.insert(offset, f);
	}

	public StringBuilder insert(int offset, double d) {
		return sb.insert(offset, d);
	}

	public int indexOf(String str) {
		return sb.indexOf(str);
	}

	public int indexOf(String str, int fromIndex) {
		return sb.indexOf(str, fromIndex);
	}

	public int lastIndexOf(String str) {
		return sb.lastIndexOf(str);
	}

	public int lastIndexOf(String str, int fromIndex) {
		return sb.lastIndexOf(str, fromIndex);
	}

	public StringBuilder reverse() {
		return sb.reverse();
	}

	@Override
	public char charAt(int index) {
		return sb.charAt(index);
	}

	@Override
	public int length() {
		return sb.length();
	}

	@Override
	public CharSequence subSequence(int start, int end) {
		return sb.subSequence(start, end);
	}

}